import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/components/Login'
import User from '../views/User.vue'
import Songs from '@/components/song/Songs'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: Login
  },
  {
    path: '/home',
    redirect: '/home/index'
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/Home'),
    meta: {
      name: '首页',
    },
    children: [
      {
        path: 'index',
        name: '首页',
        component: () => import('../components/Index.vue')
      },
      {
        path: '/system/users',
        name: 'users',
        component: User,
        meta: {
          name: '系统管理 / 用户管理',
        },
      },
      {
        path: 'songs',
        name: 'songs',
        component: Songs,
        meta: {
          name: '歌曲管理',
        },
      },
      {
        path: 'songsheet',
        name: '歌单管理',
        component: () => import('../components/songsheet/SongSheet.vue'),
        meta: {
          name: '歌单管理',
        },
      },
      {
        path: 'singer',
        name: '歌手管理',
        component: () => import('../components/singer/Singer.vue'),
        meta: {
          name: '歌手管理',
        },
      },
    ]

  },

]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
